package dynProg.solvers;

public class RecursiveSolver implements Solver {

	@Override
	public boolean solve(int[] numbers, int sum) {
        if( sum == 0 ) {
            return true;
        }
        if( numbers.length == 0 ){
            return false;
        }

        int n = numbers.length - 1;
        int[] shorterNumbersCopy = new int[n];
        for(int index = 0; index < n; index++){
            shorterNumbersCopy[index] = numbers[index];
        }

        return solve(shorterNumbersCopy, sum)
            || solve(shorterNumbersCopy, sum - numbers[n]);
	}

}
